<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<div th:fragment="ueditormode"  class="am-cf">


    <!-- 加载编辑器的容器 -->
    <script id="ueditor" name="ueditor" type="text/plain">这里写你的初始化内容</script>


    <!-- 配置文件 -->
    <script type="text/javascript" src="static/ueditor1_4/ueditor.config.js"></script>
    <script type="text/javascript">
        //hewei
        function getHostPath(){
            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
            var curWwwPath=window.document.location.href;
            console.log(location.href);
            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
            var pathName=window.document.location.pathname;
            console.log("当前路径："+pathName);
            var pos=curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            var hostPath=curWwwPath.substring(0,pos);
            //获取带"/"的项目名，如：/uimcardprj
            var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
            console.log("项目路径："+hostPath);
            // return hostPath;
            return curWwwPath;
        }
        window.UEDITOR_CONFIG.serverUrl= getHostPath()+"/ueditor";
    </script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="static/ueditor1_4/ueditor.all.js"></script>

    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        // var ue = UE.getEditor('ueditor').render("ueditor");

        // 删除之前的实例，重新实例化，避免第二次无法实例化以及第一次重复渲染
        UE.delEditor('ueditor');
        var ue = UE.getEditor('ueditor');
        // console.log(window.UEDITOR_HOME_URL);
        console.log("加载初始化ueditor......");
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function(action) {
            if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                return getHostPath()+'/imgUpload';
                //'http://localhost:8080/imgUpload';为方法imgUpload的访问地址
            } else {
                return this._bkGetActionUrl.call(this, action);
            }
        }
    </script>
</div>

</html>